package com.sec.datasource.datasource.controller;

import com.sec.datasource.datasource.domain.User;
import com.sec.datasource.datasource.mapper.onedb.UserOneMapper;
import com.sec.datasource.datasource.mapper.twodb.UserTwoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("databases")
public class HelloController {

    @Autowired
    private UserOneMapper userOneMapper;

    @Autowired
    private UserTwoMapper userTwoMapper;

    @GetMapping("one")
    public Object oneUser() {
        return userOneMapper.selectList(null);
    }

    @GetMapping("two")
    public Object twoUser() {
        return userTwoMapper.selectList(null);
    }

    @GetMapping("all")
    public Object allUser() {
        List<User> users = userOneMapper.selectList(null);
        users.addAll(userTwoMapper.selectList(null));
        return users;
    }

}
